package com.sjb.training.lc;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 有点儿意思
 * @Description:
 */
public class RemoveElement {
    public static void main(String[] args) {
        int[] nums =  {1,2,3,4,3};
        int element = removeElement(nums, 3);
        System.out.println(element);
    }



    public static int removeElement(int[] nums, int val) {
        int slow = 0;
        for (int fast = 0; fast < nums.length; fast++) {
            if (nums[fast] != val){
                nums[slow ++] = nums[fast];
            }
        }
        return slow;
    }
}
